package com.blog.effective.note7;

/**
 * 自定义一个重写终结方法的方法.
 *
 * @author 张俊强~.
 * @date 2017/11/27-22:17.
 */
public class MyFileOutputStream  {

    public MyFileOutputStream() {
        super();
    }

//    @Deprecated(since="9")
    protected void finalize() throws Throwable {
        System.out.println("调用终结方法");
        System.exit(0);             //调用终结方法我们强制退出
        super.finalize();
    }

//    private final Object finalizerGuardian =new Object(){
//        @Override
//        protected void finalize() throws Throwable {
//            System.out.println("调用终结方法");
//            super.finalize();
//        }
//    };
}
